/**
 * 初始化转科记录详情对话框
 */
var CdcTransferInfoDlg = {
    validateFields: {
    	xcode: {
            validators: {
                notEmpty: {
                    message: '索引码不能为空'
                }
            }
        },
    	episodeId: {
            validators: {
                notEmpty: {
                    message: '就诊记录不能为空'
                }
            }
        },
    	busTranTypeId: {
            validators: {
                notEmpty: {
                    message: '转科类型不能为空'
                }
            }
        },
    	tranLocId: {
            validators: {
                notEmpty: {
                    message: '转入科室不能为空'
                }
            }
        },
    	tranBedId: {
            validators: {
                notEmpty: {
                    message: '转入床位不能为空'
                }
            }
        },
    	fromLocId: {
            validators: {
                notEmpty: {
                    message: '转出科室不能为空'
                }
            }
        },
    	tranDate: {
            validators: {
                notEmpty: {
                    message: '转入日期不能为空'
                }
            }
        },
    	fromDate: {
            validators: {
                notEmpty: {
                    message: '转出日期不能为空'
                }
            }
        },
    	inLocDays: {
            validators: {
                notEmpty: {
                    message: '在科天数不能为空'
                }
            }
        },
    	dataId: {
            validators: {
                notEmpty: {
                    message: '业务数据类型不能为空'
                }
            }
        },
    	isActive: {
            validators: {
                notEmpty: {
                    message: '是否有效不能为空'
                }
            }
        },
    }
};


/**
 * 关闭此对话框
 */
CdcTransferInfoDlg.close = function() {
    parent.layer.close(parent.layer.getFrameIndex(window.name)); //先得到当前iframe层的索引,再执行关闭   
}

/**
 * 验证数据是否为空
 */
CdcTransferInfoDlg.validate = function () {
    $('#cdcTransferInfoForm').data("bootstrapValidator").resetForm();
    $('#cdcTransferInfoForm').bootstrapValidator('validate');
    return $("#cdcTransferInfoForm").data('bootstrapValidator').isValid();
}

/**
 * 提交新增
 */
CdcTransferInfoDlg.addSubmit = function() {

    if (!this.validate()) {
        return;
    }
    //提交信息
    Sys.ajaxForm('cdcTransferInfoForm',Sys.backendPath + "/cdc/cdctransfer/add",function(res) {
        Sys.success(res.message);
    	window.parent.CdcTransfer.table.refresh();
        CdcTransferInfoDlg.close();
    });
}

/**
 * 提交修改
 */
CdcTransferInfoDlg.editSubmit = function() {

    if (!this.validate()) {
        return;
    }
    //提交信息
    Sys.ajaxForm('cdcTransferInfoForm',Sys.backendPath + "/cdc/cdctransfer/update",function(res) {
        Sys.success(res.message);
    	window.parent.CdcTransfer.table.refresh();
        CdcTransferInfoDlg.close();
    });
}

$(function() {
	Sys.initValidator("cdcTransferInfoForm", CdcTransferInfoDlg.validateFields);
});
